open Type

module FMap = Map.Make(struct
    type t = string
    let compare x y = Pervasives.compare x y
end)

let ls = FMap.empty

(* Builtin Function Declaration Format:
 *   let ls = FMap.add MCSL_fname (MCSL_ret_tp, MCSL_arg_tp, OCaml_fname) ls
 * Where:
 *   @MCSL_fname  (string):  MCSL name of builtin function.
 *   @MCSL_ret_tp (tp):      MCSL return type.
 *   @MCSL_arg_tp (tp list): List of MCSL argument types.
 *   @OCaml_fname (strung):  Name of Ocaml function to call.
 * 
 * Basically, the MCSL function call will get replaced with call
 * to the OCaml equivalent.  The evaluated arguments will be passed.
 * e.g. if the MCSL function was called with a Vector(3), the OCaml
 * function will be called with an Array of size 3.
 *)

(*** Begining of builtin fuction declarations ***)
let ls = FMap.add "VectorLength" (Float, [Vector 0], "Vector.length") ls
let ls = FMap.add "VectorDimension" (Int, [Vector 0], "Vector.dimension") ls
let ls = FMap.add "MCaggregate" (Float, [Str;Int], "Mc.aggregate") ls  (* FIXME: correct types *)
let ls = FMap.add "MClist" (Float, [Str;Int], "Mc.list") ls  (* FIXME: correct types *)
let ls = FMap.add "MathFactorial" (Int, [Int], "Math.factorial") ls
let ls = FMap.add "RandFloat" (RFloat, [Float;Float], "Rand.floatRng") ls
let ls = FMap.add "RandInt" (RInt, [Int;Int], "Rand.intRng") ls
(*** End of builtin fuction declarations ***)

let exists fname = FMap.mem fname ls
let get_types fname = let ret_tp, arg_tp, _ = FMap.find fname ls in ret_tp, arg_tp
let get_ret_type fname = let ret_tp, _, _ = FMap.find fname ls in ret_tp
let get_name fname = let _, _, name = FMap.find fname ls in name

